package cn.java59;

import java.util.Scanner;

public class Demo8 {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.println("请输入一个四位数：");
		int sum = input.nextInt();
		System.out.println("四位数：" + sum);

		System.out.println("请加密 ");
		int gewei = (sum % 10 + 5) % 10;
		int shiwei = (sum / 10 % 10 + 5) % 10;
		int baiwei = (sum / 100 % 10 + 5) % 10;
		int qianwei = (sum / 1000 + 5) % 10;
		System.out.println("个位数：" + gewei);
		System.out.println("十位数:" + shiwei);
		System.out.println("百位数：" + baiwei);
		System.out.println("千位数:" + qianwei);

		// 赋值
		int num1 = gewei;
		int num2 = shiwei;
		int num3 = baiwei;
		int num4 = qianwei;
		// 各位和千位交换
		int no = num1;
		num1 = num4;
		num4 = no;
		// 十位和百位交换
		int no2 = num2;
		num2 = num3;
		num3 = no2;
		System.out.println("交换后");
		System.out.println("个位数:" + num1);
		System.out.println("十位数:" + num2);
		System.out.println("百位数:" + num3);
		System.out.println("千位数:" + num4);

		System.out.println("加密后");
		System.out.println("输出四位数: " + (num1 + num2 * 10 + num3 * 100 + num4 * 1000));

	}
}
